Managing Events

The Application can register for one or more events so as to be notified of the same when it occurs. There are basically two main events.

·  eventReadNotify– Notifies whenever read tag event occurs with read tag data as argument. By default, the event comes with tag data. If not required, we can disable using function setAttachTagDataWithReadEvent.

·  eventStatusNotify– Notifies whenever status event occurs with status event data as argument.

 

Event Description
GPI_EVENT  A GPI event (state change from high to low, or low to high) has occurred on a GPI port. When this event is signaled, StatusEventData contains GPI Port and GPI Event that has occurred.
BUFFER_FULL_WARNING_EVENT When the internal tag buffer is 90% full, this event will be signaled.
ANTENNA_EVENT A particular Antenna has been Connected/Disconnected. When this event is signaled, StatusEventData contains Antenna and the Connection Status that has occurred.
INVENTORY_START_EVENT Inventory Operation has started. In case of periodic trigger this event will be triggered for each period.
INVENTORY_STOP_EVENT Inventory Operation has stopped. In case of periodic trigger this event will be triggered for each period.
ACCESS_START_EVENT Access Operation has started.
ACCESS_STOP_EVENT Access Operation has stopped.
DISCONNECTION_EVENT Event notifying disconnection from the Reader. The Application can call reconnect method periodically to attempt reconnection or call disconnect method to cleanup and exit.
BUFFER_FULL_EVENT When the internal tag data buffer is 100% full, this event will be signaled and tags are discarded in FIFO manner.
NXP_EAS_ALARM_EVENT This Event is generated when Reader finds a(NXP)tag with it's EAS System bit still set to true.
READER_EXCEPTION_EVENT Event notifying that an exception has occurred in the Reader. When this event is signaled, StatusEventData.ReaderExceptionEventData.ReaderExceptionEventType can be called to know the reason for the exception which is coming as part of Events.StatusEventArgs. The Application can continue to use the connection if the reader renders is usable.
TEMPERATURE_ALARM_EVENT When Temperature reaches Threshold level, this event will be generated. The event data contains source name (PA/Ambient), current Temperature and alarm Level (Low, High or Critical)

    

// registering for read tag data notification

EventHandler eventHandler = new EventHandler();

reader.Events.addEventsListener(eventHandler);

 

// Subscribe required status notification

reader.Events.setInventoryStartEvent(true);

reader.Events.setInventoryStopEvent(true);

reader.Events.setAccessStartEvent(true);

reader.Events.setAccessStopEvent(true);

// enables tag read notification. if this is set to false, no tag read notification will be send

reader.Events.setTagReadEvent(true);

reader.Events.setAntennaEvent(true);

reader.Events.setBufferFullEvent(true);

reader.Events.setBufferFullWarningEvent(true);

reader.Events.setGPIEvent(true);

reader.Events.setReaderDisconnectEvent(true);

 

   // Read/Status Notify handler

   // Implement the RfidEventsLister class to receive event notifications

    class EventHandler implements RfidEventsListener {

    

        // Read Event Notification

        public void eventReadNotify(RfidReadEvents e){

            // Recommended to use new method getReadTagsEx for better performance in case of large tag population

            TagData[] myTags = reader.Actions.getReadTags(100);

            if (myTags != null)

            {

                for (int index = 0; index < myTags.length; index++)

                {

                    System.out.println("Tag ID " + myTags[index].getTagID());

    

                    if (myTags[index].getOpCode() == ACCESS_OPERATION_CODE.ACCESS_OPERATION_READ &&

                            myTags[index].getOpStatus() == ACCESS_OPERATION_STATUS.ACCESS_SUCCESS)

                    {

                        if (myTags[index].getMemoryBankData().length() > 0) {

                            System.out.println(" Mem Bank Data " + myTags[index].getMemoryBankData());

                        }

                    }

                }

            }

    

        }

    

        // Status Event Notification

        public void eventStatusNotify(RfidStatusEvents e) {

            System.out.println("Status Notification: " + e.StatusEventData.getStatusEventType());

        }

    }

 

// Unregistering for read tag data notification

reader.Events.removeEventsListener(eventHandler);